<?php

use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$modelItems = \common\models\Model::find()->all();
$modelItems = ArrayHelper::map($modelItems, 'id', 'name');

/* @var $this yii\web\View */
/* @var $model common\models\Attribute */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="attribute-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'model_id')->dropDownList($modelItems, ['prompt' => '选择模型...']) ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'type')->dropDownList([ 'select' => '下拉框', 'checkbox' => '复选框', 'radio' => '单选框', 'input' => '输入框', ], ['prompt' => '选择类型...']) ?>

    <?= $form->field($model, 'value')->widget(\unclead\widgets\MultipleInput::className(), [
        'columns' => [
            [
                'name' => 'value'
            ]
        ]
    ])?>

    <?= $form->field($model, 'filter')->dropDownList([0 => '不筛选', 1 => '筛选']) ?>

    <?= $form->field($model, 'order')->textInput() ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
